package tt.dz.egobus.servicemanager.business.filter;

import org.apache.commons.lang3.ArrayUtils;
import tt.dz.egobus.servicemanager.business.distance.PointFilter;
import tt.dz.egobus.servicemanager.business.point.BusPoint;

/**
 * @author Anson
 * @date 17-3-28
 * @name 判断当前businessCode中是否含有对应的业务code码
 * @since 1.0.3
 */
public class BusinessCodeValidateFilter implements PointFilter {

    private final int businessCode;

    public BusinessCodeValidateFilter(int businessCode) {
        this.businessCode = businessCode;
    }

    @Override
    public boolean isFilter(BusPoint point) {
        int[] businessCodes = point.getBusinessCodes();
        boolean isSuccess = (!ArrayUtils.isEmpty(businessCodes)) && ArrayUtils.contains(businessCodes, this.businessCode);
        return isSuccess;
    }
}
